package top.littleze.aiattendance.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.littleze.aiattendance.dto.StudentAttendanceReportDTO;
import top.littleze.aiattendance.entity.AttendanceLogEntity;
import top.littleze.aiattendance.request.CheckinRequest;
import top.littleze.aiattendance.service.StudentService;
import top.littleze.aiattendance.utils.page.Reply;

import java.util.List;

/**
 * @Author ZhaoGengze
 * @Date 2021/7/9 11:36
 */

@RestController
@ResponseBody
@RequestMapping("/student")
@Slf4j
public class StudentController {

    @Autowired
    StudentService studentService;

    /**
     * 更新个人信息
     * @param studentId
     * @return
     */
    @RequestMapping("/updateInfo")
    public Reply<Void> updateInfo(@RequestParam("studentId") String studentId) {
        log.info("学生ID：{}", studentId);
        return studentService.updateInfo(studentId);
    }

    /**
     * 学生签到
     * @param request
     * @return
     */
    @RequestMapping("/checkin")
    public Reply<Void> checkin(@RequestBody AttendanceLogEntity request) {
        log.info("签到信息：{}", request);
        return studentService.checkin(request);
    }

    /**
     * 出勤报告
     * @param studentId
     * @return
     */
    @RequestMapping("/attendanceReport")
    public Reply<List<StudentAttendanceReportDTO>> attendanceReport(@RequestParam("studentId") String studentId) {
        log.info("学生出勤报告入参: 学号：{}", studentId);
        return studentService.attendanceReport(studentId);
    }

}
